import layoutHeaderAside from '@/layout/header-aside'

// 由于懒加载页面太多的话会造成webpack热更新太慢，所以开发环境不使用懒加载，只有生产环境使用懒加载
const _import = require('@/libs/util.import.' + process.env.NODE_ENV)

/**
 * 在主框架内显示
 */
const frameIn = [
  {
    path: '/',
    redirect: { name: 'index' },
    component: layoutHeaderAside,
    children: [
      // 首页
      {
        path: 'index',
        name: 'index',
        meta: {
          auth: true
        },
        component: _import('system/index')
      },
      // 职业规划
      {
        path: 'careerpublish',
        name: 'careerpublish',
        meta: {
          title: '写职业规划',
          auth: true
        },
        component: _import('career/publish')
      },
      {
        path: 'careermanage',
        name: 'careermanage',
        meta: {
          title: '职业规划管理',
          auth: true
        },
        component: _import('career/manage')
      },
      {
        path: 'careercomment',
        name: 'careercomment',
        meta: {
          title: '职业规划点评',
          auth: true
        },
        component: _import('career/comment')
      },
      {
        path: 'careerdrafts',
        name: 'careerdrafts',
        meta: {
          title: '草稿箱',
          auth: true
        },
        component: _import('career/drafts')
      },
      {
        path: 'careerdeleted',
        name: 'careerdeleted',
        meta: {
          title: '回收站',
          auth: true
        },
        component: _import('career/deleted')
      },
      {
        path: 'myresume',
        name: 'myresume',
        meta: {
          title: '上传简历',
          auth: true
        },
        component: _import('resume/my')
      },
      {
        path: 'resumemanage',
        name: 'resumemanage',
        meta: {
          title: '简历管理',
          auth: true
        },
        component: _import('resume/manage')
      },
      {
        path: 'resumecomments',
        name: 'resumecomments',
        meta: {
          title: '简历点评',
          auth: true
        },
        component: _import('resume/comments')
      },
      {
        path: 'applyjob',
        name: 'applyjob',
        meta: {
          title: '求职指导',
          auth: true
        },
        component: _import('job/applyjob')
      },
      {
        path: 'message',
        name: 'message',
        meta: {
          title: '消息',
          auth: true
        },
        component: _import('message/message')
      },
      {
        path: 'configtimeslot',
        name: 'configtimeslot',
        meta: {
          title: '时段/专家',
          auth: true
        },
        component: _import('config/timeslot')
      },
      {
        path: 'configabout',
        name: 'configabout',
        meta: {
          title: '个人设置',
          auth: true
        },
        component: _import('config/about')
      },
      // 系统 前端日志
      {
        path: 'log',
        name: 'log',
        meta: {
          title: '前端日志',
          auth: true
        },
        component: _import('system/log')
      },
      // 刷新页面 必须保留
      {
        path: 'refresh',
        name: 'refresh',
        hidden: true,
        component: _import('system/function/refresh')
      },
      // 页面重定向 必须保留
      {
        path: 'redirect/:route*',
        name: 'redirect',
        hidden: true,
        component: _import('system/function/redirect')
      }
    ]
  }
]

/**
 * 在主框架之外显示
 */
const frameOut = [
  // 登录
  {
    path: '/login',
    name: 'login',
    component: _import('system/login')
  }
]

/**
 * 错误页面
 */
const errorPage = [
  {
    path: '*',
    name: '404',
    component: _import('system/error/404')
  }
]

// 导出需要显示菜单的
export const frameInRoutes = frameIn

// 重新组织后导出
export default [
  ...frameIn,
  ...frameOut,
  ...errorPage
]
